package com.dt.global.web.action.Articlequery;

import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;
import org.codehaus.jackson.map.ObjectMapper;
import org.hibernate.HibernateException;
import org.springframework.context.annotation.Scope;

import com.dt.components.exstruts.action.BaseActionSupport;
import com.dt.components.exutils.PageUtil;
import com.dt.global.entitys.bo.TWebCoreArticle;
import com.dt.global.entitys.bo.TWebCoreChannel;
import com.dt.global.entitys.bo.TWebCoreMien;
import com.dt.global.utils.Proerties;
import com.dt.global.web.mar.Newscentrality.NewscentralityMar;
import com.dt.global.web.mar.articleQuery.ArticleQueryMar;
import com.dt.global.web.mar.repquery.RepQueryMar;

/**
 * 栏目新闻查询的action
 * @author MWG
 *
 */
@SuppressWarnings("serial")
@Scope("prototype")
public class ArticleQueryAction   extends BaseActionSupport{
	@Resource
	public ArticleQueryMar articleQueryMar;
	@Resource
	private RepQueryMar repQueryMar;

	private String title;
	private String pid;
	@Resource
	private NewscentralityMar newscentralityMar;
	//json解析对象
	public ObjectMapper mapper=new ObjectMapper();
	/**
	 * 根据栏目Id(分页)查看栏目信息
	 */
	@SuppressWarnings("unchecked")
	public String getTWebCoreChannelPageQuery()throws HibernateException{
		try{
			Proerties popUtil = new Proerties();
			String url = popUtil.getValue("wjrdht");
			//声明List结果集，用于装载查询结果
			List<Map<String, String>> list = null;
			Map<String, String> map = null;
			HttpServletRequest request = ServletActionContext.getRequest();
			String channelId=getRequest().getParameter("channelId");
			if(channelId !=null&!channelId.equals("")){
				//根据栏目ID查询栏目信息
				TWebCoreChannel twebCoreChannel=newscentralityMar.getTWebCoreChannelId(channelId);
				this.initExtableGrid(10);// 每页显示条数
				try {
					PageUtil.setPageDispatchInfo(request,pm);
				} catch (Exception e) {
					e.printStackTrace();
					return "error";
				}
				//根据栏目分页查询栏目信息
				pm = articleQueryMar.getTWebCoreArticleChannelId(pm, channelId);
				int totalNum = pm.getRsCount();
				List<TWebCoreArticle> objList = (List<TWebCoreArticle>) pm.getRsList();
				list = new ArrayList<Map<String, String>>();
				//查询数据结果
				if(totalNum != 0){
					for(TWebCoreArticle article : objList){
						map = new HashMap<String, String>();
						if(article.getTitleImg()!=null&&!article.getTitleImg().equals("")){
							map.put("titleImg",url+"/uploadfile/"+article.getTitleImg());  	
						}else{
							map.put("titleImg",""); 
						}
						map.put("articleId", article.getArticleId());
						if(article.getTitle().length()>36){
							map.put("title", article.getTitle().substring(0,36)+"..."); 
						}else{
							map.put("title", article.getTitle());  
						}
						map.put("releaseSysDate", article.getReleaseSysDate().substring(0,10));
						list.add(map);
					}
				}
				request.setAttribute("channel", twebCoreChannel);
				request.setAttribute(prefix, list);
				request.setAttribute(prefix + "_totalRows",new Integer(totalNum));
				return  "success";
			}else{
				return "error";
			}
		}catch(Exception e){
			e.printStackTrace();
			return "error";
		}
	}
	/**
	 * 根据栏目Nid查询栏目（ajax）
	 */
	public String selectNidChannel(){
		HttpServletResponse resp = 
			ServletActionContext.getResponse();
		resp.setContentType("text/html;utf-8");
		resp.setCharacterEncoding("utf-8");
		try {
			String nid = getRequest().getParameter("nid");
			if(nid !=null&!nid.equals("")){
				List<Map<String,String>> list = new ArrayList<Map<String,String>>();
				List<TWebCoreChannel> listchannel= newscentralityMar.getTWebCoreChannelNid(nid);
				//声明Map对象
				Map<String,String> map = null;
				for (TWebCoreChannel channel : listchannel) {
					map = new HashMap<String, String>();
					map.put("name", channel.getName());
					map.put("channelId", channel.getChannelId());
					list.add(map);
				}
				String json = mapper.writeValueAsString(list);
				PrintWriter out  =resp.getWriter();
				out.print(json);
				out.flush();
				out.close();
				return null;
			}else{
				return "error";
			}
		} catch (Exception e) {
			e.printStackTrace();
			return "error";
		}
	}
	/**
	 * 根据栏目pid查询栏目（ajax）
	 */
	public String selectChannel(){
		HttpServletResponse resp = 
			ServletActionContext.getResponse();
		resp.setContentType("text/html;utf-8");
		resp.setCharacterEncoding("utf-8");
		try {
			String pid = getRequest().getParameter("pid");
			if(getRequest().getParameter("nid")!=null&&!getRequest().getParameter("nid").equals("")){
				List<Map<String,String>> list = new ArrayList<Map<String,String>>();
				List<TWebCoreChannel> listchannel= newscentralityMar.getTWebCoreChannelNid(getRequest().getParameter("nid"));
				//声明Map对象
				Map<String,String> map = null;
				for (TWebCoreChannel channel : listchannel) {
					map = new HashMap<String, String>();
					map.put("name", channel.getName());
					map.put("channelId", channel.getChannelId());
				    if(channel.getChannelId().equals("channelId201309251495139081372672")){
				    	map.put("pid", "11");
				    }else if(channel.getChannelId().equals("channelId201309251495136186483712")){
				    	map.put("pid", "12");
				    }else if(channel.getChannelId().equals("channelId201309251495136999343104")){
				    	map.put("pid", "13");
				    }else if(channel.getChannelId().equals("channelId201310301544737986085888")){
				    	map.put("pid", "22");
				    }else if(channel.getChannelId().equals("channelId201309281499199859753984")){
				    	map.put("pid", "15");
				    }else if(channel.getChannelId().equals("channelId201309251495128810669056")){
				    	map.put("pid", "16");
				    }else if(channel.getChannelId().equals("channelId201309251495134226940928")){
				    	map.put("pid", "17");
				    }else if(channel.getChannelId().equals("channelId201309251495134536139776")){
				    	map.put("pid", "18");
				    }else if(channel.getChannelId().equals("channelId201309251495134797251584")){
				    	map.put("pid", "19");
				    }else if(channel.getChannelId().equals("channelId201309251495139773809664")){
				    	map.put("pid", "20");
				    }else if(channel.getChannelId().equals("channelId201309251495139508700160")){
				    	map.put("pid", "21");
				    }
					list.add(map);
				}
				String json = mapper.writeValueAsString(list);
				PrintWriter out  =resp.getWriter();
				out.print(json);
				out.flush();
				out.close();
				return null;
			}else{
				if(pid !=null&!pid.equals("")){
					List<Map<String,String>> list = new ArrayList<Map<String,String>>();
					List<TWebCoreChannel> listchannel= newscentralityMar.getTWebCoreChannelPid(pid);
					//声明Map对象
					Map<String,String> map = null;
					for (TWebCoreChannel channel : listchannel) {
						map = new HashMap<String, String>();
						map.put("name", channel.getName());
						map.put("channelId", channel.getChannelId());
						//判断基层专栏
					    if(channel.getChannelId().equals("channelId201309251495139081372672")){
					    	map.put("pid", "11");
					    }else if(channel.getChannelId().equals("channelId201309251495136186483712")){
					    	map.put("pid", "12");
					    }else if(channel.getChannelId().equals("channelId201309251495136999343104")){
					    	map.put("pid", "13");
					    }else if(channel.getChannelId().equals("channelId201310301544737986085888")){
					    	map.put("pid", "22");
					    }else if(channel.getChannelId().equals("channelId201309281499199859753984")){
					    	map.put("pid", "15");
					    }else if(channel.getChannelId().equals("channelId201309251495128810669056")){
					    	map.put("pid", "16");
					    }else if(channel.getChannelId().equals("channelId201309251495134226940928")){
					    	map.put("pid", "17");
					    }else if(channel.getChannelId().equals("channelId201309251495134536139776")){
					    	map.put("pid", "18");
					    }else if(channel.getChannelId().equals("channelId201309251495134797251584")){
					    	map.put("pid", "19");
					    }else if(channel.getChannelId().equals("channelId201309251495139773809664")){
					    	map.put("pid", "20");
					    }else if(channel.getChannelId().equals("channelId201309251495139508700160")){
					    	map.put("pid", "21");
					    }
					   //判断是否显示温江人大网
					    if(channel.getChannelId().equals("channelId201311281585828414342144")|channel.getChannelId().equals("channelId201311281585833448342528")|
					       channel.getChannelId().equals("channelId201311281585839130952704")|channel.getChannelId().equals("channelId201311281585848800478208")|
					       channel.getChannelId().equals("channelId201311281585856996508672")|channel.getChannelId().equals("channelId201311281585862193120256")|
					       channel.getChannelId().equals("channelId201311281585792969475072")|channel.getChannelId().equals("channelId201311281585815806493696")|
					       channel.getChannelId().equals("channelId201311281585801691890688")|channel.getChannelId().equals("channelId201311281585844317635584")|
					       channel.getChannelId().equals("channelId201311281585853085156352")){
					    	map.put("flag", "true");
					    }else{
					    	map.put("flag", "false");
					    }
						list.add(map);
					}
					String json = mapper.writeValueAsString(list);
					PrintWriter out  =resp.getWriter();
					out.print(json);
					out.flush();
					out.close();
					return null;
				}else{
					return "error";
				}
			}
			
		} catch (Exception e) {
			e.printStackTrace();
			return "error";
		}
	}
	
	/**
	 * 根据栏目Id(分页)查看图片集锦栏目信息
	 */
	public String getTWebCoreChannelPicPageQuery()throws HibernateException{
		try{
			Proerties popUtil = new Proerties();
			String url = popUtil.getValue("wjrdht");
			//声明List结果集，用于装载查询结果
			List<Map<String, String>> list = null;
			Map<String, String> map = null;
			HttpServletRequest request = ServletActionContext.getRequest();
			String channelId=getRequest().getParameter("channelId");
			if(channelId !=null&!channelId.equals("")){
				//根据栏目ID查询栏目信息
				TWebCoreChannel twebCoreChannel=newscentralityMar.getTWebCoreChannelId(channelId);
				this.initExtableGrid(20);// 每页显示条数
				try {
					PageUtil.setPageDispatchInfo(request,pm);
				} catch (Exception e) {
					e.printStackTrace();
					return "error";
				}
				//根据栏目分页查询栏目信息
				pm = articleQueryMar.getTWebCoreArticleChannelId(pm, channelId);
				int totalNum = pm.getRsCount();
				List<TWebCoreArticle> objList = (List<TWebCoreArticle>) pm.getRsList();
				list = new ArrayList<Map<String, String>>();
				//查询数据结果
				if(totalNum != 0){
				//	for(TWebCoreArticle article : objList){
						for(int i=0;i<objList.size();i++){
						map = new HashMap<String, String>();
						if(i%2==0){
								String hang = "hang";
								map.put("hang", hang);
							}
						if(objList.get(i).getTitleImg()!=null&&!objList.get(i).getTitleImg().equals("")){
							map.put("titleImg",url+"/uploadfile/"+objList.get(i).getTitleImg());  	
						}else{
							map.put("titleImg",""); 
						}
						map.put("articleId", objList.get(i).getArticleId());
						if(objList.get(i).getTitle().length()>18){
							map.put("title", objList.get(i).getTitle().substring(0,18)+"..."); 
						}else{
							map.put("title", objList.get(i).getTitle());  
						}
						map.put("allTitle", objList.get(i).getTitle());
						list.add(map);
					}
				}
				request.setAttribute("channel", twebCoreChannel);
				request.setAttribute(prefix, list);
				request.setAttribute(prefix + "_totalRows",new Integer(totalNum));
				return  "success";
			}else{
				return "error";
			}
		}catch(Exception e){
			e.printStackTrace();
			return "error";
		}
	}
	/**
	 * 根据栏目Id(分页)查看基层专栏栏目信息
	 */
	@SuppressWarnings("unchecked")
	public String getTWebCoreChanneljczlPageQuery()throws HibernateException{
		try{
			Proerties popUtil = new Proerties();
			String url = popUtil.getValue("wjrdht");
			//声明List结果集，用于装载查询结果
			List<Map<String, String>> list = null;
			Map<String, String> map = null;
			HttpServletRequest request = ServletActionContext.getRequest();
			String channelId=getRequest().getParameter("channelId");
			if(channelId !=null&!channelId.equals("")){
				//根据栏目ID查询栏目信息
				TWebCoreChannel twebCoreChannel=newscentralityMar.getTWebCoreChannelId(channelId);
				this.initExtableGrid(10);// 每页显示条数
				try {
					PageUtil.setPageDispatchInfo(request,pm);
				} catch (Exception e) {
					e.printStackTrace();
					return "error";
				}
				//根据栏目分页查询栏目信息
				pm = articleQueryMar.getTWebCoreArticleChannelId(pm, channelId);
				int totalNum = pm.getRsCount();
				List<TWebCoreArticle> objList = (List<TWebCoreArticle>) pm.getRsList();
				list = new ArrayList<Map<String, String>>();
				//查询数据结果
				if(totalNum != 0){
					for(TWebCoreArticle article : objList){
						map = new HashMap<String, String>();
						if(article.getTitleImg()!=null&&!article.getTitleImg().equals("")){
							map.put("titleImg",url+"/uploadfile/"+article.getTitleImg());  	
						}else{
							map.put("titleImg",""); 
						}
						map.put("articleId", article.getArticleId());
						if(article.getTitle().length()>36){
							map.put("title", article.getTitle().substring(0,36)+"..."); 
						}else{
							map.put("title", article.getTitle());  
						}
						if(article.getReleaseSysDate()!=null&&!article.getReleaseSysDate().equals("")){
							map.put("releaseSysDate", article.getReleaseSysDate().substring(0,10));
						}
						list.add(map);
					}
				}
				request.setAttribute("channel", twebCoreChannel);
				request.setAttribute(prefix, list);
				request.setAttribute(prefix + "_totalRows",new Integer(totalNum));
				return  "success";
			}else{
				return "error";
			}
		}catch(Exception e){
			e.printStackTrace();
			return "error";
		}
	}

	/**
	 * 查询新闻详细信息(返回)
	 */
	public String getNewsInfoReturn()throws HibernateException{
		try{
			Proerties popUtil = new Proerties();
			String url = popUtil.getValue("wjrdht");
			TWebCoreChannel twebCoreChannel=null;
			//声明List结果集，用于装载查询结果
			HttpServletRequest request = ServletActionContext.getRequest();
			String articleId=getRequest().getParameter("articleId");
			if(articleId !=null&!articleId.equals("")){
				//根据新闻Id查询新闻信息
				TWebCoreArticle twebCoreArticle=articleQueryMar.getTWebCoreArticleId(articleId);
				if(twebCoreArticle.getChannelId()!=null&&!twebCoreArticle.getChannelId().equals("")){
					//根据栏目ID查询栏目信息
					twebCoreChannel=newscentralityMar.getTWebCoreChannelId(twebCoreArticle.getChannelId());
					request.setAttribute("channel", twebCoreChannel);
				}
				if(twebCoreArticle.getExlink()!=null&&twebCoreArticle.getExlink().length()!=0){
					if(twebCoreArticle.getExlink().contains("http://")){
						String newExlink=twebCoreArticle.getExlink().replace("http://", "");
						twebCoreArticle.setExlink(newExlink);
					}
				}else{
					twebCoreArticle.setExlink("");
				}
				if(twebCoreArticle.getAttachment()!=null&&twebCoreArticle.getAttachment().length()!=0){
					twebCoreArticle.setAttachment(url+"/UploadFiles"+twebCoreArticle.getAttachment());
				}else{
					twebCoreArticle.setAttachment("");
				}
				if(twebCoreArticle.getAttaName()!=null&&twebCoreArticle.getAttaName().length()!=0){
					twebCoreArticle.setAttaName(twebCoreArticle.getAttaName());
				}else{
					twebCoreArticle.setAttaName("");
				}
				if(twebCoreArticle.getViewAddress()!=null&&twebCoreArticle.getViewAddress().length()!=0){
					twebCoreArticle.setViewAddress(url+"/flv"+twebCoreArticle.getViewAddress());
				}else{
					twebCoreArticle.setViewAddress("");
				}
				if(twebCoreArticle.getViewName()!=null&&twebCoreArticle.getViewName().length()!=0){
					twebCoreArticle.setViewName(twebCoreArticle.getViewName());
				}else{
					twebCoreArticle.setViewName("");
				}
				if(twebCoreArticle.getAuthor()!=null&&twebCoreArticle.getAuthor().length()!=0){
					twebCoreArticle.setAuthor(twebCoreArticle.getAuthor());
				}else{
					twebCoreArticle.setAuthor("");
				}
				request.setAttribute("article", twebCoreArticle);
				if(twebCoreChannel!=null&&twebCoreChannel.getPid().equals("08")){
					return "jczl";
				}else{
					return  "success";
				}

			}else{
				return "error";
			}
		}catch(Exception e){
			e.printStackTrace();
			return "error";
		}
	}
	
	/**
	 * 查询代表风采详细信息(返回)
	 */
	public String getRepNewsInfoReturn()throws HibernateException{
		try{
			Proerties popUtil = new Proerties();
			String url = popUtil.getValue("wjrdht");
			TWebCoreChannel twebCoreChannel=null;
			//声明List结果集，用于装载查询结果
			HttpServletRequest request = ServletActionContext.getRequest();
			String articleId=getRequest().getParameter("articleId");
			if(articleId !=null&!articleId.equals("")){
				//根据新闻Id查询新闻信息
				TWebCoreMien twebCoreMine=repQueryMar.getTWebCoreArticleId(articleId);
				if(twebCoreMine.getChannelId()!=null&&!twebCoreMine.getChannelId().equals("")){
					//根据栏目ID查询栏目信息
					twebCoreChannel=newscentralityMar.getTWebCoreChannelId(twebCoreMine.getChannelId());
					request.setAttribute("channel", twebCoreChannel);
				}
				if(twebCoreMine.getIntro()!=null&&twebCoreMine.getIntro().length()!=0){
					request.setAttribute("intro", twebCoreMine.getIntro());
				}else{
					request.setAttribute("intro", "");
				}
				if(twebCoreMine.getName()!=null&&twebCoreMine.getName().length()!=0){
					request.setAttribute("name", twebCoreMine.getName());
				}else{
					request.setAttribute("name", "");
				}
				if(twebCoreMine.getPhone()!=null&&twebCoreMine.getPhone().length()!=0){
					request.setAttribute("phone", twebCoreMine.getPhone());
				}else{
					request.setAttribute("phone", "");
				}
				if(twebCoreMine.getUnit()!=null&&twebCoreMine.getUnit().length()!=0){
					request.setAttribute("unit", twebCoreMine.getUnit());
				}else{
					request.setAttribute("unit", "");
				}
				if(twebCoreMine.getTitleImg()!=null&&twebCoreMine.getTitleImg().length()!=0){
					request.setAttribute("titleImg",url+"/uploadfile/"+twebCoreMine.getTitleImg());
				}else{
					request.setAttribute("titleImg", "");
				}
				request.setAttribute("article", twebCoreMine);
					return  "success";
			}else{
				return "error";
			}
		}catch(Exception e){
			e.printStackTrace();
			return "error";
		}
	}
	/**
	 * 查询新闻详细信息(关闭)
	 */
	public String getNewsInfoClose()throws HibernateException{
		try{
			Proerties popUtil = new Proerties();
			String url = popUtil.getValue("wjrdht");
			TWebCoreChannel twebCoreChannel=null;
			//声明List结果集，用于装载查询结果
			HttpServletRequest request = ServletActionContext.getRequest();
			String articleId=getRequest().getParameter("articleId");
			if(articleId !=null&!articleId.equals("")){
				//根据新闻Id查询新闻信息
				TWebCoreArticle twebCoreArticle=articleQueryMar.getTWebCoreArticleId(articleId);
				if(twebCoreArticle.getChannelId()!=null&&!twebCoreArticle.getChannelId().equals("")){
					//根据栏目ID查询栏目信息
					twebCoreChannel=newscentralityMar.getTWebCoreChannelId(twebCoreArticle.getChannelId());
					request.setAttribute("channel", twebCoreChannel);
				}
				if(twebCoreArticle.getExlink()!=null&&twebCoreArticle.getExlink().length()!=0){
					if(twebCoreArticle.getExlink().contains("http://")){
						String newExlink=twebCoreArticle.getExlink().replace("http://", "");
						twebCoreArticle.setExlink(newExlink);
					}
				}else{
					twebCoreArticle.setExlink("");
				}
				if(twebCoreArticle.getAttachment()!=null&&twebCoreArticle.getAttachment().length()!=0){
					twebCoreArticle.setAttachment(url+"/UploadFiles"+twebCoreArticle.getAttachment());
				}else{
					twebCoreArticle.setAttachment("");
				}
				if(twebCoreArticle.getAttaName()!=null&&twebCoreArticle.getAttaName().length()!=0){
					twebCoreArticle.setAttaName(twebCoreArticle.getAttaName());
				}else{
					twebCoreArticle.setAttaName("");
				}
				if(twebCoreArticle.getViewAddress()!=null&&twebCoreArticle.getViewAddress().length()!=0){
					twebCoreArticle.setViewAddress(url+"/flv"+twebCoreArticle.getViewAddress());
				}else{
					twebCoreArticle.setViewAddress("");
				}
				if(twebCoreArticle.getViewName()!=null&&twebCoreArticle.getViewName().length()!=0){
					twebCoreArticle.setViewName(twebCoreArticle.getViewName());
				}else{
					twebCoreArticle.setViewName("");
				}
				if(twebCoreArticle.getAuthor()!=null&&twebCoreArticle.getAuthor().length()!=0){
					twebCoreArticle.setAuthor(twebCoreArticle.getAuthor());
				}else{
					twebCoreArticle.setAuthor("");
				}
				request.setAttribute("article", twebCoreArticle);
				return  "success";
			}else{
				return "error";
			}
		}catch(Exception e){
			e.printStackTrace();
			return "error";
		}
	}
	/**
	 * 新闻搜索
	 */
	@SuppressWarnings("unchecked")
	public String getsearchPageQuery()throws HibernateException{
		try{
			//声明List结果集，用于装载查询结果
			List<Map<String, String>> list = null;
			Map<String, String> map = null;
			String path = getRequest().getContextPath();
			String zhi="";
			if(pid==null){
				pid="10";
			}
			if(pid.equals("11")){//万春镇
				getRequest().setAttribute("topimage",path+"/images/logo_wc.png");
				zhi="zsuccess";
			}else if(pid.equals("13")){ //和盛镇
				getRequest().setAttribute("topimage",path+"/images/logo_hs.png");
				zhi="zsuccess";
			}else if(pid.equals("15")){ //永宁镇
				getRequest().setAttribute("topimage",path+"/images/logo_yn.png");
				zhi="zsuccess";
			}else if(pid.equals("12")){ //寿安镇
				getRequest().setAttribute("topimage",path+"/images/logo_sa.png");
				zhi="zsuccess";
			}else if(pid.equals("16")){ //柳城街道
				getRequest().setAttribute("topimage",path+"/images/logo_lc.png");
				zhi="jdsuccess";
			}else if(pid.equals("22")){ //文教卫体口
				getRequest().setAttribute("topimage",path+"/images/logo_wjtwk.png");
				zhi="jdsuccess";
			}else if(pid.equals("17")){ //天府街道
				getRequest().setAttribute("topimage",path+"/images/logo_tf.png");
				zhi="jdsuccess";
			}else if(pid.equals("18")){ //涌泉街道
				getRequest().setAttribute("topimage",path+"/images/logo_yq.png");
				zhi="jdsuccess";
			}else if(pid.equals("19")){ //公平街道
				getRequest().setAttribute("topimage",path+"/images/logo_gp.png");
				zhi="jdsuccess";
			}else if(pid.equals("20")){ //永盛镇
				getRequest().setAttribute("topimage",path+"/images/logo_ys.png");
				zhi="zsuccess";
			}else if(pid.equals("21")){ //金马镇
				getRequest().setAttribute("topimage",path+"/images/logo_jm.png");
				zhi="zsuccess";
			}else{
				zhi="success";
			}
			HttpServletRequest request = ServletActionContext.getRequest();
			if(title !=null&!title.equals("")){
				this.initExtableGrid(10);// 每页显示条数
				try {
					PageUtil.setPageDispatchInfo(request,pm);
				} catch (Exception e) {
					e.printStackTrace();
					return "error";
				}
				//根据栏目分页查询栏目信息
				pm = articleQueryMar.getTWebCoreArticleTitle(pm, title, pid);
				int totalNum = pm.getRsCount();
				List<TWebCoreArticle> objList = (List<TWebCoreArticle>) pm.getRsList();
				list = new ArrayList<Map<String, String>>();
				//查询数据结果
				if(totalNum != 0){
					for(TWebCoreArticle article : objList){
						map = new HashMap<String, String>();
						map.put("articleId", article.getArticleId());
						if(article.getTitle().length()>50){
							map.put("title", article.getTitle().substring(0,50)+"..."); 
						}else{
							map.put("title", article.getTitle());  
						}
						if(article.getReleaseSysDate()!=null&&!article.getReleaseSysDate().equals("")){
							map.put("releaseSysDate", article.getReleaseSysDate().substring(0,10));
						}
						if(article.getChannelId().equals("channelId201311281585812086719488")||article.getChannelId().equals("channelId201311281585843436504064")||article.getChannelId().equals("channelId201311281585852308620288")||article.getChannelId().equals("channelId201311281585859512108032")||article.getChannelId().equals("channelId201311281585791233901568")||article.getChannelId().equals("channelId201311281585825302283264")||article.getChannelId().equals("channelId201311281585832735966208")||article.getChannelId().equals("channelId201311281585796510499840")||article.getChannelId().equals("channelId201311281585838351238144")||article.getChannelId().equals("channelId201311281585848140366848")||article.getChannelId().equals("channelId201311281585854509745152")){
							map.put("showPic", "yes");
						}else{
							map.put("showPic", "no");
						}
						list.add(map);
					}
				}
				request.setAttribute("title1", title);
				request.setAttribute(prefix, list);
				request.setAttribute(prefix + "_totalRows",new Integer(totalNum));
				request.setAttribute("pid",pid);
				request.setAttribute("title1",title);
				return zhi;
			}else{
				return "error";
			}
		}catch(Exception e){
			e.printStackTrace();
			return "error";
		}
	}
	/**
	 * 根据栏目id分页查看代表风采
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public String getdaibiaofcPageQuery()throws HibernateException{
		try{
			Proerties popUtil = new Proerties();
			String url = popUtil.getValue("wjrdht");
			//声明List结果集，用于装载查询结果
			List<Map<String, String>> list = null;
			Map<String, String> map = null;
			HttpServletRequest request = ServletActionContext.getRequest();
			String channelId=getRequest().getParameter("channelId");
			if(channelId !=null&!channelId.equals("")){
				//根据栏目ID查询栏目信息
				TWebCoreChannel twebCoreChannel=newscentralityMar.getTWebCoreChannelId(channelId);
				this.initExtableGrid(15);// 每页显示条数
				try {
					PageUtil.setPageDispatchInfo(request,pm);
				} catch (Exception e) {
					e.printStackTrace();
					return "error";
				}
				//根据栏目分页查询栏目信息
				pm = articleQueryMar.getdaibiaofcPageQuery(pm, channelId);
				int totalNum = pm.getRsCount();
				List<TWebCoreMien> objList = (List<TWebCoreMien>) pm.getRsList();
				list = new ArrayList<Map<String, String>>();
				//查询数据结果
				if(totalNum != 0){
					for(int i=0;i<objList.size();i++){
						map = new HashMap<String, String>();
						if(objList.get(i).getTitleImg()!=null&&!objList.get(i).getTitleImg().equals("")){
							map.put("titleImg",url+"/uploadfile/"+objList.get(i).getTitleImg());  	
						}else{
							map.put("titleImg",""); 
						}
						map.put("zhi",String.valueOf(i));
						if(objList.get(i).getName()!=null&&!objList.get(i).getName().equals("")){
							map.put("name",objList.get(i).getName());
						}
						if(objList.get(i).getArticleId()!=null&&!objList.get(i).getArticleId().equals("")){
							map.put("articleId", objList.get(i).getArticleId());
						}
						list.add(map);
					}
				}
				request.setAttribute("channel", twebCoreChannel);
				request.setAttribute(prefix, list);
				request.setAttribute(prefix + "_totalRows",new Integer(totalNum));
				return  "success";
			}else{
				return "error";
			}
		}catch(Exception e){
			e.printStackTrace();
			return "error";
		}
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public String getPid() {
		return pid;
	}
	public void setPid(String pid) {
		this.pid = pid;
	}

}
